-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API nits + refactor #704
API nits + refactor #704
Conversation
Signed-off-by: Aaron Sutula <hi@asutula.com>
Signed-off-by: Aaron Sutula <hi@asutula.com>
Signed-off-by: Aaron Sutula <hi@asutula.com>
Signed-off-by: Aaron Sutula <hi@asutula.com>
Signed-off-by: Aaron Sutula <hi@asutula.com>
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. | ||
@echo "(re)installing $(GOBIN)/protoc-gen-go-v1.25.0" | ||
@cd .bingo && $(GO) build -modfile=protoc-gen-go.mod -o=$(GOBIN)/protoc-gen-go-v1.25.0 "google.golang.org/protobuf/cmd/protoc-gen-go" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protoc-gen-go
and protoc-gen-go-grpc
now managed by and accessed through bingo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
@@ -94,7 +94,7 @@ jobs: | |||
replace-with: "" | |||
- name: Generate JS gRPC bindings | |||
run: | | |||
./scripts/gen-js-protos.sh ${{steps.makeversion.outputs.replaced}} . ./js-grpc | |||
./scripts/gen-js-protos.sh ${{steps.makeversion.outputs.replaced}} ./proto ./js-grpc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
./proto/
is now the "root" of our proto files... ./proto/
itself is not part of the proto path, it's just the container for all protos and the actual proto paths are relative to this root.
protos: install-protoc clean-protos | ||
PATH=$(PROTOCGENGO):$(PATH) ./scripts/protoc_gen_plugin.bash --proto_path=. --plugin_name=go --plugin_out=. --plugin_opt=plugins=grpc,paths=source_relative | ||
protos: $(BUF) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) clean-protos | ||
$(BUF) generate --template '{"version":"v1beta1","plugins":[{"name":"go","out":"api/gen","opt":"paths=source_relative","path":$(PROTOC_GEN_GO)},{"name":"go-grpc","out":"api/gen","opt":"paths=source_relative","path":$(PROTOC_GEN_GO_GRPC)}]}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using buf
to generate the Go protos. buf
actually supports configuring this via a config file, which is really nice, but I needed to pass the location of the buf
, protoc-gen-go
, and protoc-gen-go-grpc
binaries managed by Bingo in dynamically, so I instead used buf
's flag for passing the config in as json on the command line.
) | ||
|
||
// Admin provides access to Powergate admin APIs. | ||
type Admin struct { | ||
StorageJobs *StorageJobs | ||
Profiles *Profiles | ||
Users *Users |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New "user" wording in the client. Feels much easier and makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that user feels weird, but I definitely prefer it over storage profile.
"github.com/textileio/powergate/ffs/manager" | ||
"github.com/textileio/powergate/ffs/scheduler" | ||
"github.com/textileio/powergate/wallet" | ||
) | ||
|
||
// Service implements the Admin API. | ||
type Service struct { | ||
adminPb.UnimplementedAdminServiceServer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required by the new version of gRPC to help with evolving the API moving forward. That type just provides default implementations of the service that returning unimplemented
errors.
- . | ||
excludes: | ||
- buildtools | ||
- proto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That new root
lint: | ||
use: | ||
- DEFAULT | ||
except: | ||
- PACKAGE_VERSION_SUFFIX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are doing the version suffix now
@@ -1,9 +1,9 @@ | |||
syntax = "proto3"; | |||
package proto.admin.v1; | |||
package powergate.admin.v1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using proto
as the root allows the package to be more proper like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I like the changes!
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. | ||
@echo "(re)installing $(GOBIN)/protoc-gen-go-v1.25.0" | ||
@cd .bingo && $(GO) build -modfile=protoc-gen-go.mod -o=$(GOBIN)/protoc-gen-go-v1.25.0 "google.golang.org/protobuf/cmd/protoc-gen-go" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
install-protoc: | ||
cd buildtools && ./protocInstall.sh | ||
|
||
PROTOCGENGO=$(shell pwd)/buildtools/protoc-gen-go | ||
protos: install-protoc clean-protos | ||
PATH=$(PROTOCGENGO):$(PATH) ./scripts/protoc_gen_plugin.bash --proto_path=. --plugin_name=go --plugin_out=. --plugin_opt=plugins=grpc,paths=source_relative | ||
protos: $(BUF) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) clean-protos | ||
$(BUF) generate --template '{"version":"v1beta1","plugins":[{"name":"go","out":"api/gen","opt":"paths=source_relative","path":$(PROTOC_GEN_GO)},{"name":"go-grpc","out":"api/gen","opt":"paths=source_relative","path":$(PROTOC_GEN_GO_GRPC)}]}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, the protocInstall.sh
was a stretch, this looks more maintainable.
) | ||
|
||
// Admin provides access to Powergate admin APIs. | ||
type Admin struct { | ||
StorageJobs *StorageJobs | ||
Profiles *Profiles | ||
Users *Users |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that user feels weird, but I definitely prefer it over storage profile.
@@ -3,26 +3,26 @@ package admin | |||
import ( | |||
"context" | |||
|
|||
proto "github.com/textileio/powergate/proto/admin/v1" | |||
adminPb "github.com/textileio/powergate/api/gen/powergate/admin/v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, the /gen
subpath makes clear is gRPC releated.
While integrating the Powergate v1.0.0 update into Hub, I felt a few things I wanted to change here before the v1.x Powergate become widely deployed/used.
These updates mostly are related to trying to get the proto files and generated code perfect so they can become stable and we can start doing proper backward compatible proto updates moving forward (minimize breaking changes).
There are just a few small but important changes here that led to a hundred files being updated simply because of renaming of a couple things and moving the generated proto code (most file updates are generated cli docs, and every gRPC service file and client file was updated because of new import paths for generated proto code). Here is what changed:
Job
toStorageJob
just since we're being clear about storage jobs vs retrieval jobs elsewhere in the codebase.Client.Users.Create()
andClient.Users.List()
are the new names.api/gen
directory. This is nice because the proto types are part of the public api, and now all client and server imports come fromgit.luolix.top/textileio/powergate/api
and its sub packages.buf
,protoc-gen-go
andprotoc-gen-go-grpc
)... no morebuildtools
folder and script! Much cleaner.buf
's code generation also made it easy to update to the new/current versions ofprotoc-gen-go
andprotoc-gen-go-grpc
which I've been meaning to do for a while. Our previous code generation shell script would have needed some updating that wasn't quite clear to me, but usingbuf
's declarative code generation configuration made this easy.